<%@ page contentType="text/html;charset=utf-8"%>
<%@ include file="/login/common/taglibs.jsp"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.math.BigDecimal"%>

<%@ page import="cn.mogugo.joke.model.JokeObj"%>

<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="cn.mogugo.joke.manager.JokeObjManager"%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />  
<SCRIPT LANGUAGE="JavaScript">
<!--


	//checkbox中至少有一项被选中
	function atleaseOneCheck(){
		var items = document.getElementsByName('chbItemlist');
		if(items.length>0){
			for (var i = 0; i < items.length; i++)
			{
				if (items[i].checked == true)
				{
					return true;
				}
			}
		}else{
			if(items.checked == true){
				  return true;		   	 
			}
		}
		return false;
	}

	function operateRecoldByFormNo(action , str , formNo){

		var checkOk;
		if(str == ""){
			checkOk = true;
		}else{
			if (confirm(str)){
				if (!atleaseOneCheck()){
					alert('请至少选择一条记录！');
					checkOk = false;
					return;
				}else{
					checkOk = true;
				}
			}else{
				checkOk = false;
			}
		}
		if(checkOk){
			var form = document.forms[formNo];
			form.action = action;
			form.submit();	
		}
		
	}
//-->
</SCRIPT>

</head>

<body>
<a href="/joke/obj.do?method=sameTitleDiffContent">重复</a>


<html:form  action="/joke/obj.do?method=sameList">
<TABLE border="1" cellspacing="0" cellpadding="3" width="99%">
<TR>
	<TD>序号</TD>
	<TD>标题</TD>
	<TD>数量</TD>
	<TD>相似度</TD>
</TR>
<%

	WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletConfig().getServletContext());        
	JokeObjManager jokeObjManager = (JokeObjManager)context.getBean("jokeObjManager");
	
	String strMethod = pageContext.getRequest().getParameter("method");
	String checkboxOn = "";
	if(strMethod.equals("sameTitleDiffContent")){
		checkboxOn = "checked";
	}

	List list = (List)request.getAttribute("page");
	if(list != null){
		for(int i = 0 ; i < list.size() ; i ++ ){
			Map mapOfCol = (Map)list.get(i);

			String joke_title = (String)mapOfCol.get("JOKE_TITLE");
			Integer sn = ((Long)mapOfCol.get("SN")).intValue();
			Object objDl = mapOfCol.get("diffLevel");
			
%>
<TR>
	<TD width="40"><%=i + 1%></TD>
	<TD width="600"><%=joke_title%><a href="/joke/obj.do?method=ignore&jokeTitle=<%=joke_title%>" onclick="{if(confirm('确定要忽略所有?')){return true;}return false;}">忽略</a><a href=""></TD>
	<TD width="40"><%=sn%></TD>
	<TD width="40">
		<%
			if(objDl != null){
		%>
		<%=(Double)objDl%>
		<%
			}else{	
		%>
		/
		<%
			}	
		%>
	</TD>
</TR>

<%
			List listContent = jokeObjManager.getByJokeTitle(joke_title);
			for(int j = 0 ; j < listContent.size() ; j ++ ){
				String isChecked = "";
				if(j == 0){
					isChecked = checkboxOn;
				}
				JokeObj jo = (JokeObj)listContent.get(j);
%>
<TR>
	<TD colspan="3" style="background:#EDF7FF;"><%=jo.getJoke_content()%></TD>
	<TD><input id="chbItemlist" type="checkbox" name="chbItemlist" value="<%=i%>_<%=jo.getId()%>" style="border:0px;width: 39px; height: 39px;" <%=isChecked%>/></TD>

</TR>
<%
			}
		}

	}

	System.out.println(list.size());
%>
</TABLE>
<br>
<div style="float:left;">
	<span style="float:right;">
	<a href="javascript:operateRecoldByFormNo('/joke/obj.do?method=deleteSame' , '确定要删除记录?' , 0)">删除</a>
	
	</span>
	${pageStr}
</div>
</html:form>
</body>
</html>
